home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / dev / gg / ncurses-5.3.lha / ncurses-5.3 / Ada95 / gen / terminal_interface-curses-mouse < prev    next >
Text File  |  2002-10-24  |  8KB  |  185 lines

  1. --  -*- ada -*-
  2. define(`HTMLNAME',`terminal_interface-curses-mouse__ads.htm')dnl
  3. include(M4MACRO)dnl
  4. ------------------------------------------------------------------------------
  5. --                                                                          --
  6. --                           GNAT ncurses Binding                           --
  7. --                                                                          --
  8. --                      Terminal_Interface.Curses.Mouse                     --
  9. --                                                                          --
  10. --                                 S P E C                                  --
  11. --                                                                          --
  12. ------------------------------------------------------------------------------
  13. -- Copyright (c) 1998 Free Software Foundation, Inc.                        --
  14. --                                                                          --
  15. -- Permission is hereby granted, free of charge, to any person obtaining a  --
  16. -- copy of this software and associated documentation files (the            --
  17. -- "Software"), to deal in the Software without restriction, including      --
  18. -- without limitation the rights to use, copy, modify, merge, publish,      --
  19. -- distribute, distribute with modifications, sublicense, and/or sell       --
  20. -- copies of the Software, and to permit persons to whom the Software is    --
  21. -- furnished to do so, subject to the following conditions:                 --
  22. --                                                                          --
  23. -- The above copyright notice and this permission notice shall be included  --
  24. -- in all copies or substantial portions of the Software.                   --
  25. --                                                                          --
  26. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  --
  27. -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               --
  28. -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   --
  29. -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   --
  30. -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    --
  31. -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    --
  32. -- THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               --
  33. --                                                                          --
  34. -- Except as contained in this notice, the name(s) of the above copyright   --
  35. -- holders shall not be used in advertising or otherwise to promote the     --
  36. -- sale, use or other dealings in this Software without prior written       --
  37. -- authorization.                                                           --
  38. ------------------------------------------------------------------------------
  39. --  Author:  Juergen Pfeifer, 1996
  40. --  Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en
  41. --  Version Control:
  42. --  $Revision: 1.21 $
  43. --  Binding Version 01.00
  44. ------------------------------------------------------------------------------
  45. include(`Mouse_Base_Defs')
  46. with System;
  47.  
  48. package Terminal_Interface.Curses.Mouse is
  49.    pragma Preelaborate (Terminal_Interface.Curses.Mouse);
  50.  
  51.    --  MANPAGE(`curs_mouse.3x')
  52.    --  Please note, that in ncurses-1.9.9e documentation mouse support
  53.    --  is still marked as experimental. So also this binding will change
  54.    --  if the ncurses methods change.
  55.    --
  56.    --  mouse_trafo, wmouse_trafo are implemented as Transform_Coordinates
  57.    --  in the parent package.
  58.    --
  59.    --  Not implemented:
  60.    --  REPORT_MOUSE_POSITION (i.e. as a parameter to Register_Reportable_Event
  61.    --  or Start_Mouse)
  62.    type Event_Mask is private;
  63.    No_Events  : constant Event_Mask;
  64.    All_Events : constant Event_Mask;
  65.  
  66.    type Mouse_Button is (Left,     -- aka: Button 1
  67.                          Middle,   -- aka: Button 2
  68.                          Right,    -- aka: Button 3
  69.                          Button4,  -- aka: Button 4
  70.                          Control,  -- Control Key
  71.                          Shift,    -- Shift Key
  72.                          Alt);     -- ALT Key
  73.  
  74.    subtype Real_Buttons  is Mouse_Button range Left .. Button4;
  75.    subtype Modifier_Keys is Mouse_Button range Control .. Alt;
  76.  
  77.    type Button_State is (Released,
  78.                          Pressed,
  79.                          Clicked,
  80.                          Double_Clicked,
  81.                          Triple_Clicked);
  82.  
  83.    type Button_States is array (Button_State) of Boolean;
  84.    pragma Pack (Button_States);
  85.  
  86.    All_Clicks : constant Button_States := (Clicked .. Triple_Clicked => True,
  87.                                            others => False);
  88.    All_States : constant Button_States := (others => True);
  89.  
  90.    type Mouse_Event is private;
  91.  
  92.    --  MANPAGE(`curs_mouse.3x')
  93.  
  94.    function Has_Mouse return Boolean;
  95.    --  Return true if a mouse device is supported, false otherwise.
  96.  
  97.    procedure Register_Reportable_Event
  98.      (Button : in Mouse_Button;
  99.       State  : in Button_State;
  100.       Mask   : in out Event_Mask);
  101.    --  Stores the event described by the button and the state in the mask.
  102.    --  Before you call this the first time, you should init the mask
  103.    --  with the Empty_Mask constant
  104.    pragma Inline (Register_Reportable_Event);
  105.  
  106.    procedure Register_Reportable_Events
  107.      (Button : in Mouse_Button;
  108.       State  : in Button_States;
  109.       Mask   : in out Event_Mask);
  110.    --  Register all events described by the Button and the State bitmap.
  111.    --  Before you call this the first time, you should init the mask
  112.    --  with the Empty_Mask constant
  113.  
  114.    --  ANCHOR(`mousemask()',`Start_Mouse')
  115.    --  There is one difference to mousmask(): we return the value of the
  116.    --  old mask, that means the event mask value before this call.
  117.    --  Not Implemented: The library version
  118.    --  returns a Mouse_Mask that tells which events are reported.
  119.    function Start_Mouse (Mask : Event_Mask := All_Events)
  120.                          return Event_Mask;
  121.    --  AKA
  122.    pragma Inline (Start_Mouse);
  123.  
  124.    procedure End_Mouse (Mask : in Event_Mask := No_Events);
  125.    --  Terminates the mouse, restores the specified event mask
  126.    pragma Inline (End_Mouse);
  127.  
  128.    --  ANCHOR(`getmouse()',`Get_Mouse')
  129.    function Get_Mouse return Mouse_Event;
  130.    --  AKA
  131.    pragma Inline (Get_Mouse);
  132.  
  133.    procedure Get_Event (Event  : in  Mouse_Event;
  134.                         Y      : out Line_Position;
  135.                         X      : out Column_Position;
  136.                         Button : out Mouse_Button;
  137.                         State  : out Button_State);
  138.    --  !!! Warning: X and Y are screen coordinates. Due to ripped of lines they
  139.    --  may not be identical to window coordinates.
  140.    --  Not Implemented: Get_Event only reports one event, the C library
  141.    --  version supports multiple events, e.g. {click-1, click-3}
  142.    pragma Inline (Get_Event);
  143.  
  144.    --  ANCHOR(`ungetmouse()',`Unget_Mouse')
  145.    procedure Unget_Mouse (Event : in Mouse_Event);
  146.    --  AKA
  147.    pragma Inline (Unget_Mouse);
  148.  
  149.    --  ANCHOR(`wenclose()',`Enclosed_In_Window')
  150.    function Enclosed_In_Window (Win    : Window := Standard_Window;
  151.                                 Event  : Mouse_Event) return Boolean;
  152.    --  AKA
  153.    --  But : use event instead of screen coordinates.
  154.    pragma Inline (Enclosed_In_Window);
  155.  
  156.    --  ANCHOR(`mouseinterval()',`Mouse_Interval')
  157.    function Mouse_Interval (Msec : Natural := 200) return Natural;
  158.    --  AKA
  159.    pragma Inline (Mouse_Interval);
  160.  
  161. private
  162.    type Event_Mask is new Interfaces.C.unsigned_long;
  163.  
  164.    type Mouse_Event is
  165.       record
  166.          Id      : Integer range Integer (Interfaces.C.short'First) ..
  167.                                  Integer (Interfaces.C.short'Last);
  168.          X, Y, Z : Integer range Integer (Interfaces.C.int'First) ..
  169.                                  Integer (Interfaces.C.int'Last);
  170.          Bstate  : Event_Mask;
  171.       end record;
  172.    pragma Convention (C, Mouse_Event);
  173.    pragma Pack (Mouse_Event);
  174.  
  175. include(`Mouse_Event_Rep')
  176.    Generation_Bit_Order : constant System.Bit_Order := System.M4_BIT_ORDER;
  177.    --  This constant may be different on your system.
  178.  
  179. include(`Mouse_Events')
  180.  
  181.    No_Events  : constant Event_Mask := 0;
  182.    All_Events : constant Event_Mask := ALL_MOUSE_EVENTS;
  183.  
  184. end Terminal_Interface.Curses.Mouse;
  185.